﻿<Window x:Class="RL.wStationMoney"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Вокзальные ведомости" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" xmlns:my="clr-namespace:RL" Loaded="Window_Loaded" Closing="Window_Closing" Height="263" Width="800" >
    <Window.Resources>
        <CollectionViewSource x:Key="vokzalTableViewSource" d:DesignSource="{d:DesignInstance my:VokzalTable, CreateList=True}" >
            <!--<CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="datedoc"/>
            </CollectionViewSource.SortDescriptions>-->
        </CollectionViewSource>
        <my:RoutesTypeConverter x:Key="RoutesTypeConverter" />
        <my:RouteListTypeConverter x:Key="RouteListTypeConverter" />
    </Window.Resources>
    <Grid DataContext="{StaticResource vokzalTableViewSource}">
        <Grid.RowDefinitions>
            <RowDefinition Height="35" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Name="stackPanel1" Orientation="Horizontal">
            <Button Content="Добавить" Height="23" Name="buttonAdd" Width="75" Click="buttonAdd_Click"/>
            <Button Content="Удалить" Height="23" Name="buttonDelete" Width="75" Click="buttonDelete_Click"/>
            <Button Content="Редактировать" Height="23" Name="buttonEdit" Width="113" Click="buttonEdit_Click"/>
            <Button Content="Сохранить" Height="23" Name="buttonSave" Width="75" Click="buttonSave_Click"/>
        </StackPanel>
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Grid.Row="1" ItemsSource="{Binding}" Name="vokzalTableDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" CanUserDeleteRows="False" CanUserAddRows="False">
            <DataGrid.Columns>
                <DataGridTemplateColumn x:Name="datedocColumn" Header="Дата" Width="90">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding Path=datedoc, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="numdocColumn" Binding="{Binding Path=numdoc}" Header="Номер" Width="200" />
                <DataGridTextColumn x:Name="id_routelistColumn" Binding="{Binding Path=id_routelist, Converter={StaticResource RouteListTypeConverter}}" Header="Путевой лист" Width="200" IsReadOnly="True"/>
                <DataGridTextColumn x:Name="id_routeColumn" Binding="{Binding Path=id_route, Converter={StaticResource RoutesTypeConverter}}" Header="Маршрут" Width="SizeToHeader" IsReadOnly="True" />
                <DataGridTextColumn x:Name="time_departureColumn" Binding="{Binding Path=time_departure}" Header="Время выезда" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="qnt_ticketsColumn" Binding="{Binding Path=qnt_tickets}" Header="Кол-во билетов" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="summa_ticketsColumn" Binding="{Binding Path=summa_tickets}" Header="Сумма билетов" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="sum_insuranceColumn" Binding="{Binding Path=sum_insurance}" Header="Сумма страхования" Width="SizeToHeader" />
                <DataGridCheckBoxColumn x:Name="delColumn" Binding="{Binding Path=del}" Header="Выкл." Width="SizeToHeader" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
